import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

export default new Router({
        mode: "history",
        routes: [{
                path: '/',

                redirect: '/login',

            },
            {
                path: '/login',
                name: 'login',
                component: () =>
                    import ('../views/Login'),
            },
            {
                path: '/index',
                name: 'index',
                component: () =>
                    import ('../views/Index'),
                children: [{
                        path: '/homePage',
                        name: 'homePage',
                        component: () =>
                            import ('../router-link/homePage'),
                    },
                    {
                        path: '/task',
                        name: 'task',
                        component: () =>
                            import ('../router-link/task'),
                    },
                    {
                        path: '/mytask',
                        name: 'mytask',
                        component: () =>
                            import ('../router-link/mytask'),
                    },
                    {
                        path: '/recommend',
                        name: 'recommend',
                        component: () =>
                            import ('../router-link/recommend'),
                    },
                    {
                        path: '/community',
                        name: 'community',
                        component: () =>
                            import ('../router-link/community'),
                    },

                    {
                        path: '/course',
                        name: 'course',
                        component: () =>
                            import ('../router-link/course'),
                    },
                    {
                        path: '/answer',
                        name: 'answer',
                        component: () =>
                            import ('../router-link/answer'),
                    },
                    {
                        path: '/teacherRead',
                        name: 'teacherRead',
                        component: () =>
                            import ('../router-link/teacherRead'),
                    },
                    {
                        path: '/booksearchinfo',
                        name: 'booksearchinfo',
                        component: () =>
                            import ('../router-link/booksearchinfo'),
                    },
                    {
                        path: '/bookinfo',
                        name: 'bookinfo',
                        component: () =>
                            import ('../router-link/bookinfo'),
                    },

                ]
            },



            {
                path: '*',
                component: () =>
                    import ('../views/404'),

            },
        ]
    })
    // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}